package com.plateno.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import com.plateno.service.SensitiveWordInitService;

/**
 * 定时任务配置类
 * 
 * @author Francis Dong
 *
 */
@Configuration
@EnableScheduling
public class SchedulingConfig {

	protected final Logger log = LoggerFactory.getLogger(getClass());


	@Autowired
	private SensitiveWordInitService sensitiveWordInitService;

	
	//每天4点执行
	@Scheduled(cron="0 0 4 * * ?")
	public void syncLoadSummaryTask() {
		log.info("加载敏感词库开始");
		try{
			this.sensitiveWordInitService.loadKeyWord();
		}catch(Exception e){
			log.error("加载敏感词库开始任务失败", e);
		}
		log.info("加载敏感词库定时任务结束");
	}
}
